home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / tcl / tests / lreplace.test < prev    next >
Text File  |  1993-02-14  |  3KB  |  96 lines

  1. # Commands covered:  lreplace
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright 1991 Regents of the University of California
  8. # Permission to use, copy, modify, and distribute this
  9. # software and its documentation for any purpose and without
  10. # fee is hereby granted, provided that this copyright notice
  11. # appears in all copies.  The University of California makes no
  12. # representations about the suitability of this software for any
  13. # purpose.  It is provided "as is" without express or implied
  14. # warranty.
  15. #
  16. # $Header: /rel/cvsfiles/devo/tcl/tests/lreplace.test,v 1.1.1.1 1992/11/07 04:46:57 zoo Exp $ (Berkeley)
  17.  
  18. if {[string compare test [info procs test]] == 1} then {source defs}
  19.  
  20. test lreplace-1.1 {lreplace command} {
  21.     lreplace {1 2 3 4 5} 0 0 a
  22. } {a 2 3 4 5}
  23. test lreplace-1.2 {lreplace command} {
  24.     lreplace {1 2 3 4 5} 1 1 a
  25. } {1 a 3 4 5}
  26. test lreplace-1.3 {lreplace command} {
  27.     lreplace {1 2 3 4 5} 2 2 a
  28. } {1 2 a 4 5}
  29. test lreplace-1.4 {lreplace command} {
  30.     lreplace {1 2 3 4 5} 3 3 a
  31. } {1 2 3 a 5}
  32. test lreplace-1.5 {lreplace command} {
  33.     lreplace {1 2 3 4 5} 4 4 a
  34. } {1 2 3 4 a}
  35. test lreplace-1.6 {lreplace command} {
  36.     lreplace {1 2 3 4 5} 4 5 a
  37. } {1 2 3 4 a}
  38. test lreplace-1.7 {lreplace command} {
  39.     lreplace {1 2 3 4 5} -1 -1 a
  40. } {a 2 3 4 5}
  41. test lreplace-1.8 {lreplace command} {
  42.     lreplace {1 2 3 4 5} 2 end a b c d
  43. } {1 2 a b c d}
  44. test lreplace-1.9 {lreplace command} {
  45.     lreplace {1 2 3 4 5} 0 3
  46. } {5}
  47. test lreplace-1.10 {lreplace command} {
  48.     lreplace {1 2 3 4 5} 0 4
  49. } {}
  50. test lreplace-1.11 {lreplace command} {
  51.     lreplace {1 2 3 4 5} 0 1
  52. } {3 4 5}
  53. test lreplace-1.12 {lreplace command} {
  54.     lreplace {1 2 3 4 5} 2 3
  55. } {1 2 5}
  56. test lreplace-1.13 {lreplace command} {
  57.     lreplace {1 2 3 4 5} 3 end
  58. } {1 2 3}
  59. test lreplace-1.14 {lreplace command} {
  60.     lreplace {1 2 3 4 5} -1 4 a b c
  61. } {a b c}
  62. test lreplace-1.15 {lreplace command} {
  63.     lreplace {a b "c c" d e f} 3 3
  64. } {a b "c c" e f}
  65. test lreplace-1.16 {lreplace command} {
  66.     lreplace { 1 2 3 4 5} 0 0 a
  67. } {a 2 3 4 5}
  68. test lreplace-1.17 {lreplace command} {
  69.     lreplace {1 2 3 4 "5 6"} 4 4 a
  70. } {1 2 3 4 a}
  71. test lreplace-1.18 {lreplace command} {
  72.     lreplace {1 2 3 4 {5 6}} 4 4 a
  73. } {1 2 3 4 a}
  74.  
  75. test lreplace-2.1 {lreplace errors} {
  76.     list [catch lreplace msg] $msg
  77. } {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
  78. test lreplace-2.2 {lreplace errors} {
  79.     list [catch {lreplace a b} msg] $msg
  80. } {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
  81. test lreplace-2.3 {lreplace errors} {
  82.     list [catch {lreplace x a 10} msg] $msg
  83. } {1 {expected integer but got "a"}}
  84. test lreplace-2.4 {lreplace errors} {
  85.     list [catch {lreplace x 10 x} msg] $msg
  86. } {1 {bad index "x": must be integer or "end"}}
  87. test lreplace-2.5 {lreplace errors} {
  88.     list [catch {lreplace x 10 1x} msg] $msg
  89. } {1 {expected integer but got "1x"}}
  90. test lreplace-2.6 {lreplace errors} {
  91.     list [catch {lreplace x 3 2} msg] $msg
  92. } {1 {first index must not be greater than second}}
  93. test lreplace-2.7 {lreplace errors} {
  94.     list [catch {lreplace x 1 1} msg] $msg
  95. } {1 {list doesn't contain element 1}}
  96.